package com.badibadi.infos;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.List;

import android.os.Environment;

/**
 * 搜索文本框将其保存起来
 * 
 * @author Administrator
 * 
 */
public class AutoFinsishEdittext implements Serializable {

	private static final long serialVersionUID = 413905333947384035L;

	/**
	 * 数据存储路径
	 */
	private String path = Environment.getExternalStorageDirectory().toString()
			+ "/" + "com.badibadi.uniclubber" + "/" + "files";

	/**
	 * 查询
	 */
	private String[] msg;

	FileOutputStream fl;
	ObjectOutputStream f;

	FileInputStream fs;
	ObjectInputStream os;

	public String[] getMsg() {
		return msg;
	}

	public void setMsg(String[] msg) {
		this.msg = msg;
	}

	public void saveMsg() {
		try {
			fl = new FileOutputStream(path);
			f = new ObjectOutputStream(fl);

			AutoFinsishEdittext a = new AutoFinsishEdittext();
			a = (AutoFinsishEdittext) os.readObject();

			f.writeObject(a);

		} catch (Exception e) {
			// TODO Auto-generated catch block
			   
		} finally {
			try {
				f.close();
				fl.close();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				   
			}

		}
	}

	// 读取sex.ser文件
	public List<String> LoadMsg() {
		AutoFinsishEdittext a = new AutoFinsishEdittext();
		try {
			fs = new FileInputStream(path);
			os = new ObjectInputStream(fs);

			//    (os.readObject());

			a = (AutoFinsishEdittext) os.readObject();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			   
			//    ();
		}
		return (List<String>) a;
	}

}
